define(function(require, exports, module) {
    var myPub = require('./public');
    var oShadow = $('.js_shadow'); //阴影
    var oTip = $('.js_yu_e_detail');       // 点击弹出弹出层
    var olayer = $('.js_layer').html();    // 弹层内容
    var time_tip = null;
    // ------------------2018年3月16日17:28:36-------------------------
    var oCoverageMain = $('.js_coverageMain'); //全额保障说明内容
    var oCoverageList = $('.js_coverageList'); //全额保障tag
    var oCoverage_button = $('.js_coverage_button'); //全额保障说明确定按钮
    // ------------------2018年3月16日17:28:36-------------------------

    oShadow.on("touchmove",function(e) {e.preventDefault()});
    // 购买返现规则说明弹窗
    oTip.hammer().on('tap',function () {
        clearTimeout(time_tip);
        //myPub.OffMuiEvent(true);
        time_tip = setTimeout(function () {
            myPub.TipLayerLongClose(' ',olayer,'no');
        },300);
        myPub.HamstopPropaga();
    });


    // -----------------2018年4月25日16:30:29-------------------------------------

    var moveHeight = oCoverageMain.outerHeight(true);
    oCoverageMain.css({'bottom': -moveHeight });

    //显示全额保障详细内容
    oCoverageList.hammer().on('tap',function(e) {
        oCoverageMain.show().stop().animate({ 'bottom':0 },300,function() {
            oShadow.show();
        });
        myPub.HamstopPropaga();
        myPub.OffMuiEvent(false);
    });

    //全额保障说明确定按钮
    oCoverage_button.hammer().on('tap',function(e) {
        oCoverageMain.stop().animate({bottom:-moveHeight},300,function(){
            oCoverageMain.hide();
            oShadow.hide();
            myPub.OffMuiEvent(true);
        });
        $(document).off('touchmove');
        myPub.HamstopPropaga()
    });
    // 阴影点击关闭
    oShadow.hammer().on('tap', function () {
        var bSideOff = true;
        //隐藏全额保障说明
        oCoverageMain.stop().animate({bottom:-moveHeight},300,function(){
            oCoverageMain.hide();
            oShadow.hide();
            bSideOff = true
        });
        myPub.HamstopPropaga();
        if(typeof mui !== 'undefined'){
            myPub.OffMuiEvent(true);
        }

    });
    // --------------------2018年4月25日17:48:44-----------------------------------

    // 全额保障  标签个数判断
    var promiseTag = $(".js_promise-tag");
    if (promiseTag.find("li").length > 2) {
        promiseTag.addClass("long");
    } else {
        promiseTag.removeClass("long");
    }


    // 全额保障详细内容的显示内容判断，以及右上角图标选择性显示
    var promiseCon = $('.js_promise-tag li');
    var selectTemp = []
    var promiseDea = $('.js_coverage_quality p');
    promiseCon.each(function(i, e) {
            selectTemp.push(e.getAttribute('data-priority'));
    })
    promiseDea.each(function(index, ele) {
        if (selectTemp.indexOf(ele.getAttribute('data-priority'))==-1 ) {
            ele.parentNode.style.display = "none";
        }
    })
        // 全额保障  选择性显示哪些左下角图标
        // 以上变量表示字符优先级，priority=1的优先级最高
    var selectImg = $('.js_selctImg img')
    if (selectTemp.indexOf("1") > -1) {
        selectImg.attr('src', selectImg.data('src0'))
    } else if (selectTemp.indexOf("2") > -1) {
        selectImg.attr('src', selectImg.data('src1'))
    } else if (selectTemp.indexOf("3") > -1) {
        selectImg.attr('src', selectImg.data('src2'))
    } else {
        selectImg.attr('src', selectImg.data('src3'))
    }
    // 自定义属性data-src表示对应字符的图标，src0对应的是priority0的值，以此类推

});